<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加面试情况</title>
</head>
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/easyui/1.3.4/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/css/wu.css" />
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/css/icon.css" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/easyui/1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	$(function() {
		var hour = '${interview.hour}';
		if (eval(hour) > 12) {
			$("#mstime2").attr("checked", true);
		} else {
			$("#mstime1").attr("checked", true);
		}

		var iid = '${interview.iid}';
		if (iid != null && iid != 0) {
			$("#button").val("修改");
		} else {
			$("#button").val("添加");
		}

	});

	function add() {

		var hour = $("[name='hour']").val();
		var minute = $("[name='minute']").val();

		hour = hour != null ? hour : 00;
		minute = minute != "" ? minute : "00";

		var mstime = hour + ":" + minute;
		$("[name='mstime']").val(mstime);
		$.post(
			"/ylq/addInterview",
			$("#a").serialize(),
			function (obj){
				if(obj){
					alert("成功");
				}else{
					alert("失败");
				}
			},
			"json"
		);
	}

	function updateTime() {
		var hour = $("#s1").val();
		if(hour!=null){
			var m1 = $("#mstime1").prop("checked");
			var m2 = $("#mstime2").prop("checked");
			if (m1 != false || m2 != false) {
				if (m1 && hour > 12) {
					alert("上午时间小于12");
					$("#s1").val("");
				} else if (m2 && hour < 12) {
					alert("下午时间大于12");
					$("#s1").val("");
				}
			}else{
				if(hour > 12){
					$("#mstime2").attr("checked",true);
				}else{
					$("#mstime1").attr("checked",true);
				}
			}
		}
	}
</script>
<body>
	<form id="a">
		<table border="1px red solid">
			<tr>
				<th colspan="11"><span style="font-size: 20px">${date }</span>
				</th>
			</tr>
			<tr>
				<th>学生姓名</th>
				<td>${student.sname }<input type="hidden"
					value="${student.sid }" name="sid"> <input type="hidden"
					value="${date }" name="time"> <input type="hidden"
					name="mstime"> <input type="hidden" name="iid"
					value="${interview.iid }">
				</td>
			</tr>
			<tr>
				<th>学生班级</th>
				<td>${student.className }</td>
			</tr>
			<tr>
				<th>面试公司</th>
				<td><input id="pwd" name="company" type="text"
					class="easyui-validatebox" data-options="required:true"
					value="${interview.company }" /></td>
			</tr>
			<tr>
				<th>有无前指导</th>
				<td><input type="radio" name="firstguideflag" value=1
					<c:if test="${interview.firstguideflag==1 }">checked=true</c:if>>有
					<input type="radio" value=0 name="firstguideflag"
					<c:if test="${interview.firstguideflag==0 }">checked=true</c:if>>无</td>
			</tr>
			<tr>
				<th>有无后指导</th>
				<td><input type="radio" name="laterguideflag" value=1
					<c:if test="${interview.laterguideflag==1 }">checked=true</c:if>>有
					<input type="radio" value=0 name="laterguideflag"
					<c:if test="${interview.laterguideflag==1 }">checked=true</c:if>>无</td>
			</tr>
			<tr>
				<th>面试时间</th>
				<td><input type="radio" id="mstime1" name="time1"
					onclick="anniu()">上午 <input type="radio" id="mstime2"
					name="time1" onclick="anniu()">下午<br /> <input id="s1"
					class="easyui-numberspinner" style="width: 80px;"
					data-options="min:0,max:23" name="hour" value="${interview.hour }"
					onchange="updateTime()"> : <input id="s2"
					class="easyui-numberspinner" style="width: 80px;"
					data-options="min:0,max:59" name="minute"
					value="${interview.minute }"></td>
			</tr>
			<tr>
				<td colspan="11"><input type="button" onclick="add()"
					id="button"> <input type="reset" value="重置"></td>
			</tr>
		</table>
	</form>
</body>
</html>